extends PanelContainer
class_name View

var _controller : Controller
@onready var label: Label = $MarginContainer/VBoxContainer/MarginContainer2/MarginContainer/Label

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	bind_all_buttons(self)
	
func bind_all_buttons(node):
	# 如果节点是Button类型
	if node is Button:
		node.pressed.connect(self._on_button_pressed.bind(node.text))
	# 遍历该节点的子节点
	for child in node.get_children():
		bind_all_buttons(child)

## 按钮按下信号绑定
func _on_button_pressed(text: String) -> void:
	_controller.input_value(text)

func _on_display_changed(text: String) -> void:
	label.text = text
